<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>{$head[title]}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="{$head[keywords]}" name="keywords" />
<meta content="{$head[description]}" name="description" />
<base href="{SITE_URL}" />
<link href="favicon.ico" rel="shortcut icon" />
<link href="../skin/style.css" rel="stylesheet" type="text/css" />
<link href="{SKIN_PATH}modal.css" rel="stylesheet" type="text/css" />
<link rel="alternate" type="application/rss+xml" title="{$head[title]}" href="/rss.php?rssid={$catid}" />
<script language="JavaScript" src="misc/config.js"></script>
<script language="JavaScript" src="misc/jquery.min.js"></script>
<script language="JavaScript" src="misc/common.js"></script>
<script language="JavaScript" src="misc/validator.js"></script>

<script type="text/javascript" src="misc/validator.js"></script>
</head>
<body>

{template 'header.html'}

<div class="container">


<div class="main">

	<div class="mod">
        <div class="head">话题：<a style="float:left;" href="{url($url)}">{$title}</a></div>
        <div class="body">
            <ul class="comments">
                {loop $comments['info'] $comment}
                <li>
                    <div class="pic"><img src="{php echo avatar($comment['userid']) ? avatar($comment['userid']) : 'misc/nophoto.gif'}" width="60" height="60"/></div>
                    <div class="text">
                        <h2>{$comment['addtime']} {$comment['username']}  {$comment['ip']} </h2>
                        <p>{$comment['content']}</p>
                    </div>
                </li>
                {/loop}
            </ul>
            
            <div class="pagination">{$pages}</div> 
        </div>
    </div> 
    
     
   <div class="mod">
        <div class="head">发布评论</div>
        <div class="body">
        	{php //list($keyid, $verify) = keyid_make('content', 'title', $contentid);}
            <form action="?module=comment&action=addpost" method="post" onSubmit="return checkForm();">
                <input type="hidden" name="contentid" value="{$contentid}"/>
                <input type="hidden" name="keyid" value="{$keyid}"/>
                <input type="hidden" name="verify" value="{$verify}"/>
            <ul>
              <li>
                <textarea cols="100" rows="8" name="comment" id="comment" onFocus="reply_clearfield()" onBlur="reply_restoration()"></textarea>
              </li>
              <li style="text-align:left;margin-left:1%;margin-top:1%;">
                <span id="checker"><div style="float:left">验证码：</div><input type="text" style="ime-mode: disabled;" size="6" id="checkcode" name="checkcode" /><img src="misc/checkcode/checkcode.php" id="code_img" onClick="this.src='misc/checkcode/checkcode.php?'+Math.random()" alt="点击换一张"></span>
                <input id="dosubmit" name="dosubmit" type="submit" value="发表评论" />
              </li>
            </ul>
            </form>
        </div>
    </div>
	
       
  </div>


	<div class="aside">
          
          <div class="mod">
            	<div class="head">热门评论</div>
                <div class="body">
                	<ul>
                  <!--{get sql="select * from table_comment" rows="10"}-->
                   {php //list($keyid, $verify) = keyid_make('content', 'title', $r[conentid]);}
                    <li><a href="?module=comment&keyid={$r[keyid]}">{$r[content]}</a></li>
                  <!--{/get}-->
                  </ul>
                </div>
            </div> 
    </div>
    
</div>


<script type="text/javascript" src="{SKIN_PATH}comment/comment.js"></script>
  <script type="text/javascript">
  <!--
    $().ready(function() {        
        if(setting.ischecklogin == 0 && getcookie('auth') === null)
        {
            $('#comment').val("请您登陆后发表评论！");
            $('#comment').attr("disabled","disabled");
            $('#dosubmit').attr("disabled","disabled");
        }
        else 
        {
            $('#comment').val("我也来说两句！");
        }
    });
    function reply_restoration()
    {
        if($('#comment').val() == '')
        {
            $('#comment').val("我也来说两句！");
        }
    }
    function reply_clearfield()
    {
        if ($('#comment').val() == "我也来说两句！") 
        {
            $('#comment').val("");   
        }
        document.getElementById('code_img').style.display = 'block';document.getElementById('code_img').src='misc/checkcode/checkcode.php';
    }
    function checkForm()
    {
        if($('#comment').val() == '' || $('#comment').val() == "我也来说两句！")
        {
            alert("内容不能为空");
            $('#comment').focus();
            return false;
        }
        if($('#checkcode').val() == '' )
        {
            alert("验证码不能为空");
            $('#checkcode').focus();
            return false;
        }
        if ($('#comment').val().length > 1000) 
        {
            alert("内容太长，最多 1000 个文字");
            return false;
        }
    }
  //-->
  </script>
<script language="javascript" type="text/javascript">
$().ready(function() {
	  $('#comment').val("我也来说两句！");
	});

function ajaxload(commentid) 
{
    //var title = {$title}; 
    var data = "&commentid="+commentid+"&keyid={$keyid}&verify={$verify}" ;
    var url =  "?module=comment&action=ajaxpost";
    $.ajax({
         type: "POST",
         url: url,
         data: data,
         success: function(msg){
            $('#repley_layer').html(msg);
         }
    }); 
}

function voteFor(id)
{
		this.id = id;
		var url = "comment/?action=vote";
		var data = '&id='+id + '&field=support';
		$.ajax({
			url: url,
			data: data,
			type: 'post',
			success :function (msg){
				$('#count_'+ id+'_1').text(msg);
			}
		});
	}
/**
* 反对
**/
function voteAgainst (id )
{
	this.id = id;
	var url  = "comment/?action=vote";
	var data = '&id='+id + '&field=against';
	$.ajax({
		url: url,
		data: data,
		type: 'post',
		success :function (msg){
			$('#count_'+ id +'_0').text(msg);
		}
	});
}

function checkForm()
{
	if($('#comment').val() == '' || $('#comment').val() == "我也来说两句！")
	{
		alert("内容不能为空");
		$('#comment').focus();
		return false;
	}
    if($('#checkcode').val() == '' )
	{
		alert("验证码不能为空");
		$('#checkcode').focus();
		return false;
	}
    if ($('#comment').val().length > 1000)
    {
        alert("内容太长，最多 1000 个文字");
        return false;
    } 
    /*if( getcookie('{$keyid}') )
    {
        alert("请不要灌水");
		return false;
    }*/
    
    
}
function close() 
{
    $("#repley_layer").html("");
}
</script>

{template 'footer.html'}
